package ru.cannabis.auth;

import org.apache.mina.core.session.IoSession;
import org.springframework.beans.factory.annotation.Autowired;
import ru.cannabis.database.hbm.PlayerDao;
import ru.cannabis.game.player.Player;

/**
 * Created with IntelliJ IDEA.
 * User: Администратор
 * Date: 10.03.13
 * Time: 3:10
 * To change this template use File | Settings | File Templates.
 */
public class AuthService
{
    //@Autowired
    //private PlayerService playerService;

    @Autowired
    private PlayerDao playerDao;

    //@Autowired
    //private GameService gameService;

    public boolean authorize(String vkId, IoSession session)
    {
        boolean result = false;

        Player player = playerDao.getByVkId(vkId);

        if (player != null)
        {
            //playerService.addPlayer(session, player);
            result = true;

            System.out.println("AUTH SUCCESS");
        }
        else
        {
            // CREATE CHAR

            System.out.println("CREATE CHAR NEEDED");
        }

        return result;
    }

    /*public boolean isAuthorized(IoSession session) {
        return playerService.containsPlayer(session);
    }

    public Player getBySession(IoSession session) {
        return playerService.getPlayer(session);
    }

    public boolean unauthorize(IoSession session) {
        playerService.removeSession(session);
        return true;
    }*/
}
